#include <stdio.h>

void dayin(int arr[], int len) {
	for (int i = 0; i < len; i++) {
		printf("%d ", arr[i]);
	}
	printf("\n");
}

void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;
}

void quicksort(int arr[], int len, int low, int high) {
	if (low < high) {
		int i = low + 1;
		int j = high;
		while (i < j) {
			if (arr[low] < arr[i]) {
				swap(&arr[i], &arr[j]);
				j--;
			} else {
				i++;
			}
		}

		if (arr[low] <= arr[i]) {
			i--;
		}
		swap(&arr[low], &arr[i]);
		dayin(arr, len);
		quicksort(arr, len, low, i);
		quicksort(arr, len, j, high);
	}
}

int main() {
	int arr[] = {1, 3, 1, 1, 7, 2, 9, 6, 1, 8, 5};
	int len = sizeof(arr) / sizeof(arr[0]);
	printf("排序之前: ");
	dayin(arr, len);
	quicksort(arr, len, 0, len - 1);
	printf("排序之后:" );
	dayin(arr, len);
	return 0;
}
